package maosy.poi.util.test

import maosy.poi.util.ExcelUtil
import maosy.poi.util.test.beans.User
import org.junit.Test
import java.io.File
import java.io.FileOutputStream
import java.math.BigDecimal
import java.util.*

class POIExcelTest {

    @Test
    fun test() {
        println("this is test.")
    }

    @Test
    fun utilTest() {


        try {
            val data = arrayListOf(
                User(1, "张三", true, 26, BigDecimal(5000), Date()),
                User(2, "李四", false, 22, BigDecimal(10000), Date())
            )
            val work = ExcelUtil.generator(null, data)

            val data2 = arrayListOf(
                User(3, "张三", true, 18, BigDecimal(5000), Date()),
                User(4, "李四", false, 16, BigDecimal(10000), Date())
            )

            val work2 = ExcelUtil.generator(work, data2)

            val file = File("/Users/mario/test.xlsx")
            if (file.exists()) file.delete()
            file.createNewFile()
            work2.write(FileOutputStream(file))
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

}